#include "stdafx.h"
#include <iostream>
#include "DemoException.h"

#include "CException.h"


void testException() {
	cout << endl;
	cout << "--------------------------------------------------" << endl;

	cout << "Using exception library v" << CException::getVersion() << " as of " << CException::getBuildDate() << "." << endl;

	// Use RTII to get default exception type
	cout << CException::CLASS_TYPE <<endl;

	try {
		cout << endl;
		cout << "Trying impossible..." << endl;
		throw _CException( "Wow! something went wrong.", 1212 );
		cout << "Failed, of course" << endl;
	}
	catch (CException &e) {			// & is IMPORTANT
		cerr << "** --- EXCEPTION THROWN ---" << endl;
		cerr << "** Type: " << e.getType() << endl;
		cerr << "** Message: " << e.getMessage() << endl;
		cerr << "** Error code: " << e.getErrorCode() << endl;
		cerr << "** Fault location: " << e.getFaultLocation() << endl;
	}
	return;
}
